<template>
    <Card>
        <Row>
            <div v-for="(item,tableIndex) in tableDatas" :key="tableIndex">
                <h3>{{item.serviceName}}</h3>
                <Table :columns="oneTableTh" :data="item.datas.data"></Table>
            </div>
        </Row>
        <!-- <Modal  v-model="creditDataMxServiceImpl_detail"   title="魔蝎征信数据详情"  @on-ok="ok"   @on-cancel="cancel" width = "50%">
            <creditDataMxServiceImpl></creditDataMxServiceImpl>
        </Modal> -->
    </Card>
</template>
<script>
// import creditDataMxServiceImpl from './creditDataMxServiceImpl_detail.vue'
export default {
  name: 'loan-credit-reporting',
  // components: {
  //   creditDataMxServiceImpl
  // },
  data () {
    return {
      // creditDataMxServiceImpl_detail: false,
      serviceType: null,
      reqNo: null,
      tableDatas: [],
      oneTableTh: [
        {
          type: 'index',
          title: '序号'
        },
        {
          title: '查询结果',
          key: 'status'
        },
        {
          title: '查询时间',
          key: 'created_date'
        },
        {
          align: 'center',
          title: '操作',
          width: 150,
          key: 'action',
          render: function (h, param) {
            var vm = this
            return h('div', {}, [
              h('Button', {
                props: {
                  type: 'info',
                  size: 'small'
                },
                style: {
                  marginLeft: '10px'
                },
                on: {
                  'click' () {
                    var params = {}
                    params.loanId = param.row.loanId
                    params.serviceType = param.row.serviceType
                    params.reqNo = param.row.request_no
                    var toName = param.row.serviceType + '_detail_new'
                    //  vm.$router.push({ name: toName, query: params });
                    // vm.creditDataMxServiceImpl_detail = true
                    const {href} = vm.$router.resolve({ name: toName, query: params })
                    if (params.serviceType === 'creditDataMxTbServiceImpl') {
                      window.open('https://tenant.51datakey.com/taobao/report_data?data=' + param.row.message, '_blank')
                    } else {
                      window.open(href, '_blank')
                    }
                  }
                }

              }, '查看明细')

            ])
          }.bind(this)
        }
      ],
      $ajax: null,
      baseUrl: this.$appContext.marvels_core_approve,
      loanId: ''
    }
  },
  methods: {
    initpage: function () {
      this.loadCredit()
    },
    // 征信报告
    loadCredit: function () {
      var loanId = this.loanId
      this.$ajax.get(this.baseUrl + '/approve/process/credit_reporting/service/getDataList', {
        params: {
          loanId: loanId
        } }).then(re => {
        var data = re.data
        // console.log(data)
        this.tableDatas = data.data
      }).catch(er => {

      })
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
  },
  watch: {
    // 点击tab页签，加载数据，只加载一次
    'taskParams.loanCreditReporting' (v) {
      if (v) {
        this.loanId = this.taskParams.curLoanId
        this.initpage()
      }
    }
  },
  props: {
    taskParams: Object
  }
}
</script>
